package com.hhs.storage.task;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.hhs.storage.bean.GCustomer;
import com.hhs.storage.bean.JxcRole;
import com.hhs.storage.bean.JxcRoleUser;
import com.hhs.storage.bean.Result;
import com.hhs.storage.service.GCustomerService;
import com.hhs.storage.service.JxcRoleUserService;
import com.hhs.storage.util.DateEasy;
import org.apache.velocity.runtime.directive.Foreach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 定时任务得到的数据
 * @author Administrator
 */
@Configuration
@EnableScheduling
public class GetDataTask {
	public static final int TEST_USER_ROLE_ID=10;
	public static volatile boolean test = false;
	@Resource
	JxcRoleUserService jxcRoleUserService;
	public GetDataTask() {
	}
	/**
	 * 定时器
	 * 去除试用客户
	 */
	@Scheduled(cron = "*/200 * * * * ?")
	public void oktask() {
		EntityWrapper<JxcRoleUser> ew=new EntityWrapper<>();
		ew.eq("role_id_",TEST_USER_ROLE_ID);
		List<JxcRoleUser> list = jxcRoleUserService.selectList(ew);
		for (JxcRoleUser item :
				list) {
			DateEasy now=new DateEasy();
			DateEasy createtime=new DateEasy(item.getCreateTime());
			long[] sc = DateEasy.getDistanceTimes2(createtime.toYYYYhMMhDDhHHcMMcSS(), now.toYYYYhMMhDDhHHcMMcSS());
			if(sc[0]>=1){
				item.setRoleId("11");
				jxcRoleUserService.updateById(item);
			}
		}

	}
}
